package com.spt.ws.tasks.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.spt.core.Property;
import com.spt.core.TaskAnnotation;
import com.spt.ws.client.WebServiceBase;
import com.spt.ws.dao.IClientDao;
import com.spt.ws.tasks.ITask;

@Component(value="spbmSendBean")
@TaskAnnotation (job_name = "视频补码",  task_id="FjjToWy_spbm", group_id="fjj_to_wy", cron="0/4 * * * * ?", autoRun="N")
public class SpbmTask extends WebServiceBase implements ITask {
    private static Logger log = LogManager.getLogger("com.spt.ws.client");
    @Autowired
    private IClientDao dao;
    
    private String head = "#HEAD";
    private String end = "#END";
    @Override
    public void doTask() throws Exception {
        log.info("start spbm..........");
        /*List<Map<String,Object>> li = dao.getBFJZT();
        int i = 0,total = 0;
        StringBuffer parm = new StringBuffer(head);
        //String[] keys = new String[]{"ID","YJTM","SBID","CJDM","SJRDZ","SJRYB","JDJDM"};
        String[] keys = Property.getProperty("fjj.send.spbm").split(",");
        List<Map<String,Object>> liflag = new ArrayList<Map<String,Object>>();
        if(liflag == null) {
            log.info("getBFJZT no infomation and end.");
            return;
        }
        for(Map<String,Object> map : li){
            i++;total++;
            parm.append(this.assembleLine(keys, map));
            liflag.add(map);
            if(i == 300||total == li.size()){
                parm.append(end);
                log.info("send msg is : " + parm.toString());
                String res = callWS("getSPBM", parm.toString());
                log.info("return msg is :" + res);
                if(checkMsg(res)){
                    dao.setBFJZTFlag(liflag);
                }
                parm = new StringBuffer(head);
                liflag = new ArrayList<Map<String,Object>>();
                i = 0;
            }
        }*/
        log.info("end spbm..........");
    }

}
